package define

// AlarmDescription 告警描述
type AlarmDescription struct {
	Name          string // 告警名称
	Visible       bool   // 前端是否显示
	FirstClass    int    // 一级分类
	SecondClass   int    // 二级分类
	ConfirmTime   int    // 告警状态确认时间，单位s
	MergeType     int    // 可合并的告警类型
	MergeTimeout  int    // 合并超时时间,单位s
	MinInterval   int    // 最小间隔，单位s，用来告警限流
	MaxTimesOfDay int    // 一天告警的最大次数
}

// 告警类型
var AlarmType = map[int]AlarmDescription{
	0x00: {Name: "超声告警", Visible: true, FirstClass: 1, SecondClass: 1},
	0x01: {Name: "碰撞告警", Visible: true, FirstClass: 1, SecondClass: 1, MaxTimesOfDay: 2, MinInterval: 600},
	0x04: {Name: "停止移动", Visible: true, FirstClass: 1, SecondClass: 1},
	0x05: {Name: "急停告警", Visible: true, FirstClass: 1, SecondClass: 1},
	0x06: {Name: "算法围困", Visible: true, FirstClass: 1, SecondClass: 1},
	0x07: {Name: "回充失败", FirstClass: 1, SecondClass: 2},
	0x08: {Name: "嵌入式", FirstClass: 1, SecondClass: 2},
	0x09: {Name: "待机告警", FirstClass: 1, SecondClass: 1},
	0x0A: {Name: "低电告警", FirstClass: 1, SecondClass: 2, MinInterval: 300},
	0x0B: {Name: "电梯告警", FirstClass: 1, SecondClass: 2},
	0x0C: {Name: "雷达遮挡", FirstClass: 1, SecondClass: 1},
	0x0D: {Name: "强制转动", FirstClass: 1, SecondClass: 1},
	0x0E: {Name: "定位丢失", FirstClass: 1, SecondClass: 2},
	0x0F: {Name: "单线雷达", FirstClass: 1, SecondClass: 1},
	0x10: {Name: "多线雷达", FirstClass: 1, SecondClass: 1},
	0x11: {Name: "虚拟墙", FirstClass: 1, SecondClass: 1},
	0x12: {Name: "RGBD", FirstClass: 1, SecondClass: 1},
	0x13: {Name: "命令暂停", FirstClass: 1, SecondClass: 1},
	0x14: {Name: "识别人体", FirstClass: 1, SecondClass: 1},
	0x15: {Name: "售卖暂停", FirstClass: 1, SecondClass: 1},
	0x16: {Name: "无定位", FirstClass: 1, SecondClass: 1},
	0x17: {Name: "断充告警", FirstClass: 1, SecondClass: 2},
	0x18: {Name: "急停未复位", FirstClass: 1, SecondClass: 1},
	0x19: {Name: "轮机失控", FirstClass: 1, SecondClass: 1},
	0x1A: {Name: "轮子打滑", FirstClass: 1, SecondClass: 1},
	0x1B: {Name: "工控机内存不足", FirstClass: 1, SecondClass: 1},
	0x1C: {Name: "未检测到充电桩二维码", FirstClass: 1, SecondClass: 1},
	0x1D: {Name: "与充电桩通信失败", FirstClass: 1, SecondClass: 1},
	0x1E: {Name: "充电桩未放电", FirstClass: 1, SecondClass: 1},
	0x1F: {Name: "充电时电源无电流输入", FirstClass: 1, SecondClass: 1},
	0x20: {Name: "回充摄像头异常", FirstClass: 1, SecondClass: 1},
	0x21: {Name: "上位机异常退出", FirstClass: 1, SecondClass: 1},
	0x22: {Name: "系统磁盘不足", FirstClass: 1, SecondClass: 1, MaxTimesOfDay: 2},
	0x23: {Name: "任务启动失败", FirstClass: 1, SecondClass: 1},
	0x24: {Name: "触发定位安全保护,已停止移动", FirstClass: 1, SecondClass: 1},
	0x25: {Name: "硬件设备异常", FirstClass: 1, SecondClass: 1, MaxTimesOfDay: 2},
	0x26: {Name: "回充过程异常", FirstClass: 1, SecondClass: 1},
	0x27: {Name: "CPU占用过高", FirstClass: 1, SecondClass: 1},
	0x28: {Name: "Disk2异常", FirstClass: 1, SecondClass: 1},
	0x29: {Name: "工控机时间同步异常", FirstClass: 1, SecondClass: 1},
	0x2A: {Name: "任务时嵌入式充电中", FirstClass: 1, SecondClass: 1},
	//1xxx 售卖相关
	1001: {Name: "退款", FirstClass: 2, SecondClass: 2},
	1002: {Name: "低库存", FirstClass: 2, SecondClass: 2},
	1003: {Name: "商品加载失败", FirstClass: 2, SecondClass: 2},
	1004: {Name: "关舱超时", FirstClass: 2, SecondClass: 2},
	1005: {Name: "初始化错误", FirstClass: 2, SecondClass: 2},
	1008: {Name: "97黑屏", FirstClass: 2, SecondClass: 2},
	//2xxx 设备相关 - 未来会变更
	2001: {Name: "95离线", FirstClass: 1, SecondClass: 1, MergeType: 2010, MergeTimeout: 60, MinInterval: 600, ConfirmTime: 600},
	2002: {Name: "97离线", FirstClass: 1, SecondClass: 1, MergeType: 2010, MergeTimeout: 60, MinInterval: 600, ConfirmTime: 600},
	2003: {Name: "98离线", FirstClass: 1, SecondClass: 1, MergeType: 2010, MergeTimeout: 60, MinInterval: 600, ConfirmTime: 600},
	2004: {Name: "95开机失败", FirstClass: 1, SecondClass: 1, MergeType: 2011, MergeTimeout: 60},
	2005: {Name: "97开机失败", FirstClass: 1, SecondClass: 1, MergeType: 2011, MergeTimeout: 60},
	2006: {Name: "98开机失败", FirstClass: 1, SecondClass: 1, MergeType: 2011, MergeTimeout: 60},
	2007: {Name: "95关机失败", FirstClass: 1, SecondClass: 1, MergeType: 2012, MergeTimeout: 60},
	2008: {Name: "97关机失败", FirstClass: 1, SecondClass: 1, MergeType: 2012, MergeTimeout: 60},
	2009: {Name: "98关机失败", FirstClass: 1, SecondClass: 1, MergeType: 2012, MergeTimeout: 60},
	2010: {Name: "整机离线", FirstClass: 1, SecondClass: 1},
	2011: {Name: "开机失败", FirstClass: 1, SecondClass: 1},
	2012: {Name: "关机失败", FirstClass: 1, SecondClass: 1},
	//3xxx 广告相关
	3001: {Name: "广告投放异常", FirstClass: 1, SecondClass: 1},
	3002: {Name: "98本地存储不足", MinInterval: 3600},
	3003: {Name: "广告新订单", FirstClass: 1, SecondClass: 1},
}

type AlarmTypeST int // 告警类型
type DstStatusST int // 目标状态类型

// 场景不同，进行告警状态转换
var AlarmTypeTransform = map[AlarmTypeST]map[DstStatusST]AlarmTypeST{
	// 95离线告警
	// 期望状态失败-对应的告警
	2001: {
		0: 2007, // 关机期望的离线状态-关机失败（失败的告警）
		1: 2001, // 正常期望的在线状态-离线告警（失败的告警）
		2: 2004, // 开机期望的在线状态-开机失败（失败的告警）
	},
	// 95离线告警
	2002: {
		0: 2008, // 关机失败
		1: 2002, // 离线告警
		2: 2005, // 开机失败
	},
	// 95离线告警
	2003: {
		0: 2009, // 关机失败
		1: 2003, // 离线告警
		2: 2006, // 开机失败
	},
}
